'use strict';
/**
 * 角色菜单关联表
 */
module.exports = app => {
  const { STRING, UUID, NOW, DATE, UUIDV4 } = app.Sequelize;
  const SRoleMenu = app.model.define('SRoleMenu', {
    id: {
      type: UUID,
      primaryKey: true,
      allowNull: false,
      defaultValue: UUIDV4,
      comment: '角色id'
    },
    roleId: {
      type: STRING(36),
      allowNull: false,
      field: 'role_id',
      comment: '角色ID'
    },
    menuId: {
      type: STRING(36),
      allowNull: false,
      field: 'menu_id',
      comment: '菜单ID'
    },
    createDate: {
      type: DATE,
      defaultValue: NOW,
      field: 'create_date',
      comment: '创建时间'
    },
    updateDate: {
      type: DATE,
      defaultValue: NOW,
      field: 'update_date',
      comment: '更新时间'
    }
  }, {
    // 去除createAt，updateAt
    timestamps: false,
    // 实例对应的表名
    tableName: 's_role_menu',
    // 将createdAt对应到数据库的created_at字段
    createdAt: 'create_date',
    // 将updatedAt对应到数据库的updated_at字段
    updatedAt: 'updated_date'
  });

  SRoleMenu.associate = function () { }

  return SRoleMenu;
};